package com.example.NetworkSender.ui;

import android.view.View;
import android.widget.TextView;
import com.example.NetworkSender.Engine;

public class ReceiveListener implements View.OnClickListener {

    private Engine engine;
    private final TextView output;

    public ReceiveListener(Engine engine, TextView output) {
        this.engine = engine;
        this.output = output;
    }

    @Override
    public void onClick(View v) {
        try {
            String received = engine.receive();
            output.setText(received);
        } catch (Exception ex) {
            output.setText(ex.getMessage());
        }
    }
}
